import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpUtil;
import cn.ifloat.brick.sprofile.web.WebApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: float 2022/12/16 08:49
 */


@RunWith(SpringRunner.class)
@SpringBootTest(classes = {WebApplication.class})
public class SsoTestSprofile {


    String token = "112233445566778899";


    @Test
    public void test(){

        SaLoginModel lm = new SaLoginModel();
        lm.setDevice("WEB");
        lm.setToken("112233445566778899");
        lm.setExtra("ek1", "ev1");
        lm.setExtra("ek2", "ev2");
        lm.setExtra("ek3", "ev3");
        StpUtil.login("AF1", lm);

        SaSession session = StpUtil.getTokenSession();
        Map<String, Object> sm = new HashMap<>();
        sm.put("sk1", "sv1");
        sm.put("sk2", "sv2");
        sm.put("sk3", "sv3");
        session.refreshDataMap(sm);
    }

    @Test
    public void test1(){
        SaSession session = StpUtil.getTokenSessionByToken(token);
        System.out.println(session.getDataMap());
    }

    @Test
    public void test2(){
        try{

            int i = 1 / 0;
        }catch(Exception e){
            throw e;
        }finally {
            System.out.println("finallay");
        }
    }
}
